import React from 'react';

import { Auth as Component } from '@/pagesComponents/Auth';
import { innerUrls } from '@/shared/constants';
import { generateMetaData } from '@/shared/lib';
import { storageTokens } from '@/shared/lib/storage';
import Head from 'next/head';
import { useRouter } from 'next/navigation';

export default function Auth() {
  const router = useRouter();
  React.useEffect(() => {
    if (storageTokens.getAccessToken() || storageTokens.getRefreshToken()) {
      router.push(innerUrls.main);
    }
  }, []);

  return (
    <>
      <Head>{generateMetaData({ title: 'Вход или регистрация' })}</Head>
      <Component />
    </>
  );
}
